home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 55671 / 55671.xpi / chrome / snipit.jar / content / snipit.js < prev    next >
Text File  |  2008-04-18  |  2KB  |  65 lines

  1. window.addEventListener("load", snipit_initialize, false);
  2.  
  3. function showHideSnipIt()
  4. {
  5.     const prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
  6.     if (prefs.prefHasUserValue("snipit.contextmenuitem"))
  7.     {
  8.         var element = document.getElementById("snipit-menu");
  9.         if (element)
  10.         {
  11.             element.setAttribute("hidden", !prefs.getBoolPref("snipit.contextmenuitem"));
  12.         }
  13.     }
  14. }
  15.  
  16. function snipit()
  17. {
  18.     const prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
  19.     var host = "http://www.snip.pl";
  20.     var url = null;
  21.     var win = null;
  22.     var openpref = null;
  23.  
  24.     if (prefs.prefHasUserValue("snipit.ssl"))
  25.         if (prefs.getBoolPref("snipit.ssl") == true)
  26.             host = "https://ssl.snip.pl";
  27.     url = host + "/snip-it.php?ref=" + escape(getBrowser().currentURI.spec);
  28.  
  29.     if (prefs.prefHasUserValue("snipit.openpagein"))
  30.     {
  31.         openpref = prefs.getComplexValue("snipit.openpagein", Components.interfaces.nsISupportsString).data;
  32.         if (openpref.indexOf("self") > -1)
  33.         {
  34.             getBrowser().loadURI(url, null, null);
  35.         }
  36.         else if (openpref.indexOf("window") > -1)
  37.         {
  38.             win = window.open(url, 'SnipIt', 'dependent=no,location=yes,menubar=yes,status=yes,resizable=yes,scrollbars=yes,toolbar=yes');
  39.             win.focus();
  40.         }
  41.         else
  42.         {
  43.             win = getBrowser().addTab(url);
  44.             getBrowser().selectedTab = win;
  45.         }
  46.     }
  47.     else
  48.     {
  49.         win = getBrowser().addTab(url);
  50.         getBrowser().selectedTab = win;
  51.     }
  52. }
  53.  
  54. function snipit_initialize(event)
  55. {
  56.     try
  57.     {
  58.         showHideSnipIt();
  59.         window.removeEventListener("load", snipit_initialize, false);
  60.     }
  61.     catch(exception)
  62.     {
  63.     }
  64. }
  65.